import {bawlistDelete} from "@/api/strategy/whiteList"
import {useCreateModal} from "@/hooks"
import EditModal from './edit-modal.vue'
import {formatDate} from "@/utils/common"

const formatObj = {
    1: '启用',
    0: '禁止'
}

export const columns = [ // 进程策略
    {
        title: '策略名称',
        dataIndex: 'name',
    },
    {
        title: '测试模式',
        dataIndex: 'usingtest',
        slots: {customRender: 'usingtest'},
        slotsType: 'format',
        slotsFunc: (val) => formatObj[val]
    },
    {
        title: '启用数字证书',
        dataIndex: 'usingcertificate',
        slots: {customRender: 'usingcertificate'},
        slotsType: 'format',
        slotsFunc: (val) => formatObj[val]
    },
    {
        title: '启用网络控制',
        dataIndex: 'usingnetworkcontrol',
        slots: {customRender: 'usingnetworkcontrol'},
        slotsType: 'format',
        slotsFunc: (val) => formatObj[val]
    },
    {
        title: '启用进程保护',
        dataIndex: 'usingprocessprotection',
        slots: {customRender: 'usingprocessprotection'},
        slotsType: 'format',
        slotsFunc: (val) => formatObj[val]
    },
    {
        title: '启用文件管控',
        dataIndex: 'usingdocumentcontrol',
        slots: {customRender: 'usingdocumentcontrol'},
        slotsType: 'format',
        slotsFunc: (val) => formatObj[val]
    },
    {
        title: '启用白名单',
        dataIndex: 'usingwhitelist',
        slots: {customRender: 'usingwhitelist'},
        slotsType: 'format',
        slotsFunc: (val) => formatObj[val]
    },
    {
        title: '模板名称',
        dataIndex: 'tempname',
    },
    {
        title: '操作',
        dataIndex: 'action',
        width: 200,
        slots: {
            customRender: 'action'
        },
        actions: [
            {
                type: 'popconfirm', // 控制类型，默认为a,可选： select | button | text
                key: 'fileid', // 删除的依据，如果需要根据多个字段删除，则字段之间以英文逗号分隔开，例如： id, name
                text: '删除',
                permission: 'setting:delete',
                props: {
                  type: 'danger'
                },
                func: async ({record}, callback) => {
                    callback()
                },
            },
            {
                type: 'button', // 控制类型，默认为a,可选： select | button | text
                key: 'fileid', // 删除的依据，如果需要根据多个字段删除，则字段之间以英文逗号分隔开，例如： id, name
                text: '编辑',
                permission: 'setting:update',
                props: {
                    type: 'warning'
                },
                func: ({record}, callback) => useCreateModal(EditModal, {
                    fields: record,
                    callback
                }),
            }
        ]
    },
]
